<?php
if (isset($_SESSION["user_id"])) {
	if ($user["roleID"] >= 2) {
?>
	<ul class="nav nav-tabs nav-justified" >
		<li id = "allU" class="active"><a onclick="displayClose('allUsers','allU');">Tout les utilisateurs</a></li>
		<li id = "waitingArts"><a onclick="displayClose('waitingArticles','waitingArts');">Articles en attente</a></li>
		<li id = "allArts"><a onclick="displayClose('allArticles','allArts');">Tous les articles</a></li>
		<li id = "allComs"><a onclick="displayClose('allComments','allComs');">Tous les commentaires</a></li>
		<li id = "allPics"><a onclick="displayClose('allPictures','allPics');">Toutes les images</a></li>
	</ul>
	<div id = "allUsers" class="main main-tabs clearfix">
		<?php include_once('allUsers.html'); ?>
	</div>
	<div id = "waitingArticles" class="main main-tabs clearfix" style ="display:none;">
		<?php include_once('waitingArticles.html'); ?>
	</div>
	<div id = "allArticles" class="main main-tabs clearfix" style ="display:none;">
		<?php include_once('allArticles.html'); ?>
	</div>
	<div id = "allComments" class="main main-tabs clearfix" style ="display:none;">
		<?php include_once('allComments.html'); ?>
	</div>
	<div id = "allPictures" class="main main-tabs clearfix" style ="display:none;">
		<?php include_once('allPictures.html'); ?>
	</div>
<?php 
} else { 
?>
    <div class="main">
        <div class="alert alert-danger center-block text-center half-size">
            Vous n'avez pas les permission nécessaire pour accéder a cette page !
        </div>
    </div>
<?php }
} ?>

<script type="text/javascript">

function replace(display,close)
{
	var divToClose = document.getElementById(close);
	divToClose.style.display = 'none';
	
	var divToDisplay = document.getElementById(display);
	divToDisplay.style.display = 'block';
}

function displayPage()
{
	var divs = new Array('allUsers', 'waitingArticles', 'allArticles', 'allComments', 'allPictures');
	var tabs = new Array('allU','waitingArts','allArts','allComs','allPics');

	for (var i=0; i < 5; i++) {
		if (divs[i] == '<?php if(isset($_GET["page"])) { echo $_GET["page"]; } ?>') {
			var divToDisplay = document.getElementById(divs[i]);
			divToDisplay.style.display = 'block';

			var divActive = document.getElementById(tabs[i]);
			divActive.className = "active";
		}
		else {
			var divToClose = document.getElementById(divs[i]);
			divToClose.style.display = 'none';

			var divActive = document.getElementById(tabs[i]);
			divActive.className = "";
		}
	}
}

function displayClose(display, active)
{
	var divs = new Array('allUsers', 'waitingArticles', 'allArticles', 'allComments', 'allPictures');
	var tabs = new Array('allU','waitingArts','allArts','allComs','allPics');
	
	for(var i =0; i <5; i++)
	{
		if(tabs[i] == active)
		{
			document.getElementById(active).className = "active";
		}
		else
		{
			document.getElementById(tabs[i]).className = '';
		}
		
		if(divs[i] == display)
		{
			document.getElementById(display).style.display = 'block';
		}		
		else
		{
			document.getElementById(divs[i]).style.display = 'none';
		}
	}
}

</script>